#ifndef __H_EPOLLER_H__
#define __H_EPOLLER_H__
#include "Public.h"

namespace liu
{
	class Channel;
	class Eventloop;

	class Epoller
	{
	public:
		using VEC_CHANNEL_PTR = vector<Channel*>;
		using MAP_CHANNEL_PTR = map<int, Channel*>;
		using VEC_EPOLL_EVENT = vector<struct epoll_event>;

	public:
		Epoller(Eventloop* pLoop);
		~Epoller();

	public:
		void PollWait(int timeoutMs, VEC_CHANNEL_PTR& activeChannels);
		void UpdateChannel(Channel* pChannel);
		void RemoveChannel(Channel* pChannel);

	private:
		void fillActiveChannels(int numEvents, VEC_CHANNEL_PTR& activeChannels);
		void update(int optype, Channel* pChannel);

	private:
		int m_EpollFd;
		VEC_EPOLL_EVENT m_vecEpollEvents;
		//MAP_CHANNEL_PTR m_mapChannels;
		Eventloop* m_pOwnerLoop;
	};
}

#endif // __H_EPOLLER_H__